import Vue from 'vue';
import VueRouter from 'vue-router';
import index from '../views/index.vue';
import login from '../views/login.vue';
import forgot from '../views/forgot.vue';
Vue.use(VueRouter)

const routes = [
    // 主页
    {
        path: '/',
        name: 'index',
        component: index,
        meta: {
            index: 0,
            title: '首页'
        }
    },

    // 登录
    {
        path: '/login',
        name: 'login',
        component: login,
        meta: {
            index: 0,
            title: '登录'
        }
    },

    
    // 忘记密码
    {
        path: '/forgot',
        name: "forgot",
        component: forgot,
        meta: {
            index: 0,
            title: '忘记密码'
        }
    },

    // 修改密码
    {
        path: '/user/password',
        name: "password",
        component: () => import("../views/user/password.vue"),
        meta: {
            index: 0,
            title: '修改密码'
        }
    },

    // 视频播放页
    {
        path: "/media/video",
        name: "video",
        component: () => import('../views/media/video.vue'),
        meta: {
            index: 0,
            title: "视频"
        }
    },

    // 音频播放页
    {
        path: "/media/audio",
        name: "audio",
        component: () => import('../views/media/audio.vue'),
        meta: {
            index: 0,
            title: "音频"
        }
    },

            // 权限路由
        {
            path: '/auth/table',
            name: 'auth_table',
            component: () => import('../views/auth/table.vue'),
            meta: {
                index: 0,
                title: '权限列表'
            }
        },
        {
            path: '/auth/view',
            name: 'auth_view',
            component: () => import('../views/auth/view.vue'),
            meta: {
                index: 0,
                title: '权限详情'
            }
        },
    
    
                // 轮播图路由
        {
            path: '/slides/table',
            name: 'slides_table',
            component: () => import('../views/slides/table.vue'),
            meta: {
                index: 0,
                title: '轮播图列表'
            }
        },
        {
            path: '/slides/view',
            name: 'slides_view',
            component: () => import('../views/slides/view.vue'),
            meta: {
                index: 0,
                title: '轮播图详情'
            }
        },
                            
    
            // 论坛路由
        {
            path: '/forum/table',
            name: 'forum_table',
            component: () => import('../views/forum/table.vue'),
            meta: {
                index: 0,
                title: '论坛列表'
            }
        },
        {
            path: '/forum/view',
            name: 'forum_view',
            component: () => import('../views/forum/view.vue'),
            meta: {
                index: 0,
                title: '论坛详情'
            }
        },

        // 论坛分类路由
        {
            path: '/forum_type/table',
            name: 'forum_type_table',
            component: () => import('../views/forum_type/table.vue'),
            meta: {
                index: 0,
                title: '论坛分类列表'
            }
        },
        {
            path: '/forum_type/view',
            name: 'forum_type_view',
            component: () => import('../views/forum_type/view.vue'),
            meta: {
                index: 0,
                title: '论坛分类详情'
            }
        },
    
            // 公告路由
        {
            path: '/notice/table',
            name: 'notice_table',
            component: () => import('../views/notice/table.vue'),
            meta: {
                index: 0,
                title: '通知公告列表'
            }
        },
        {
            path: '/notice/view',
            name: 'notice_view',
            component: () => import('../views/notice/view.vue'),
            meta: {
                index: 0,
                title: '通知公告详情'
            }
        },
                
            // 评论路由
        {
            path: '/comment/table',
            name: 'comment_table',
            component: () => import('../views/comment/table.vue'),
            meta: {
                index: 0,
                title: '评论列表'
            }
        },
        {
            path: '/comment/view',
            name: 'comment_view',
            component: () => import('../views/comment/view.vue'),
            meta: {
                index: 0,
                title: '评论详情'
            }
        },
        
            // 送养用户路由
        {
            path: '/delivery_users/table',
            name: 'delivery_users_table',
            component: () => import('../views/delivery_users/table.vue'),
            meta: {
                index: 0,
                title: '送养用户列表'
            }
        },
        {
            path: '/delivery_users/view',
            name: 'delivery_users_view',
            component: () => import('../views/delivery_users/view.vue'),
            meta: {
                index: 0,
                title: '送养用户详情'
            }
        },
            // 领养用户路由
        {
            path: '/adoptive_users/table',
            name: 'adoptive_users_table',
            component: () => import('../views/adoptive_users/table.vue'),
            meta: {
                index: 0,
                title: '领养用户列表'
            }
        },
        {
            path: '/adoptive_users/view',
            name: 'adoptive_users_view',
            component: () => import('../views/adoptive_users/view.vue'),
            meta: {
                index: 0,
                title: '领养用户详情'
            }
        },
            // 宠物信息路由
        {
            path: '/pet_information/table',
            name: 'pet_information_table',
            component: () => import('../views/pet_information/table.vue'),
            meta: {
                index: 0,
                title: '宠物信息列表'
            }
        },
        {
            path: '/pet_information/view',
            name: 'pet_information_view',
            component: () => import('../views/pet_information/view.vue'),
            meta: {
                index: 0,
                title: '宠物信息详情'
            }
        },
            // 宠物种类路由
        {
            path: '/pet_species/table',
            name: 'pet_species_table',
            component: () => import('../views/pet_species/table.vue'),
            meta: {
                index: 0,
                title: '宠物种类列表'
            }
        },
        {
            path: '/pet_species/view',
            name: 'pet_species_view',
            component: () => import('../views/pet_species/view.vue'),
            meta: {
                index: 0,
                title: '宠物种类详情'
            }
        },
            // 领养信息路由
        {
            path: '/adoption_information/table',
            name: 'adoption_information_table',
            component: () => import('../views/adoption_information/table.vue'),
            meta: {
                index: 0,
                title: '领养信息列表'
            }
        },
        {
            path: '/adoption_information/view',
            name: 'adoption_information_view',
            component: () => import('../views/adoption_information/view.vue'),
            meta: {
                index: 0,
                title: '领养信息详情'
            }
        },
            // 交流信息路由
        {
            path: '/exchange_information/table',
            name: 'exchange_information_table',
            component: () => import('../views/exchange_information/table.vue'),
            meta: {
                index: 0,
                title: '交流信息列表'
            }
        },
        {
            path: '/exchange_information/view',
            name: 'exchange_information_view',
            component: () => import('../views/exchange_information/view.vue'),
            meta: {
                index: 0,
                title: '交流信息详情'
            }
        },
            // 失信名单路由
        {
            path: '/list_of_dishonesty/table',
            name: 'list_of_dishonesty_table',
            component: () => import('../views/list_of_dishonesty/table.vue'),
            meta: {
                index: 0,
                title: '失信名单列表'
            }
        },
        {
            path: '/list_of_dishonesty/view',
            name: 'list_of_dishonesty_view',
            component: () => import('../views/list_of_dishonesty/view.vue'),
            meta: {
                index: 0,
                title: '失信名单详情'
            }
        },
            // 送养反馈路由
        {
            path: '/feeding_feedback/table',
            name: 'feeding_feedback_table',
            component: () => import('../views/feeding_feedback/table.vue'),
            meta: {
                index: 0,
                title: '送养反馈列表'
            }
        },
        {
            path: '/feeding_feedback/view',
            name: 'feeding_feedback_view',
            component: () => import('../views/feeding_feedback/view.vue'),
            meta: {
                index: 0,
                title: '送养反馈详情'
            }
        },
            // 领养反馈路由
        {
            path: '/adoption_feedback/table',
            name: 'adoption_feedback_table',
            component: () => import('../views/adoption_feedback/table.vue'),
            meta: {
                index: 0,
                title: '领养反馈列表'
            }
        },
        {
            path: '/adoption_feedback/view',
            name: 'adoption_feedback_view',
            component: () => import('../views/adoption_feedback/view.vue'),
            meta: {
                index: 0,
                title: '领养反馈详情'
            }
        },
            // 帮助中心路由
        {
            path: '/help_center/table',
            name: 'help_center_table',
            component: () => import('../views/help_center/table.vue'),
            meta: {
                index: 0,
                title: '帮助中心列表'
            }
        },
        {
            path: '/help_center/view',
            name: 'help_center_view',
            component: () => import('../views/help_center/view.vue'),
            meta: {
                index: 0,
                title: '帮助中心详情'
            }
        },
            // 广告信息路由
        {
            path: '/advertising_information/table',
            name: 'advertising_information_table',
            component: () => import('../views/advertising_information/table.vue'),
            meta: {
                index: 0,
                title: '广告信息列表'
            }
        },
        {
            path: '/advertising_information/view',
            name: 'advertising_information_view',
            component: () => import('../views/advertising_information/view.vue'),
            meta: {
                index: 0,
                title: '广告信息详情'
            }
        },
    
    // 用户路由
    {
        path: '/user/table',
        name: 'user_table',
        component: () => import('../views/user/table.vue'),
        meta: {
            index: 0,
            title: '用户列表'
        }
    },
    {
        path: '/user/view',
        name: 'user_view',
        component: () => import('../views/user/view.vue'),
        meta: {
            index: 0,
            title: '用户详情'
        }
    },
    {
        path: '/user/info',
        name: 'user_info',
        component: () => import('../views/user/info.vue'),
        meta: {
            index: 0,
            title: '个人信息'
        }
    },
    // 用户组路由
    {
        path: '/user_group/table',
        name: 'user_group_table',
        component: () => import('../views/user_group/table.vue'),
        meta: {
            index: 0,
            title: '用户组列表'
        }
    },
    {
        path: '/user_group/view',
        name: 'user_group_view',
        component: () => import('../views/user_group/view.vue'),
        meta: {
            index: 0,
            title: '用户组详情'
        }
    }
]

const router = new VueRouter({
    mode: 'hash',
    base: process.env.BASE_URL,
    routes
})

router.beforeEach((to, from, next) => {
    let token = to.query.token;
    if (token) {
        $.db.set("token", token, 120);
    }
    next();
})

router.afterEach((to, from, next) => {
    let title = "宠物领养小程序-admin";
    document.title = title;
})

export default router
